﻿using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using TrackSystem.Entities.Extensions;


namespace TrackSystem.Entities.Models
{
    /// <summary>
    /// 变量表
    /// </summary>
    [Table("var")]
    public class VarTable
    {
        /// <summary>
        /// ID
        /// </summary>
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        [Display(Name = "统一标识符")]
        public int Id { get; set; }

        /// <summary>
        /// 通道名称
        /// </summary>
        [Required]
        [Display(Name = "变量名称")]        
        public required string Name { get; set; }

        /// <summary>
        /// 变量类型
        /// </summary>
        [Required]
        public VarSerialEnum Serial { get; set; }

        /// <summary>
        /// 寄存器变量，关联的传感器或者回路ID
        /// </summary>
        public int snrloopId { get; set; }


        /// <summary>
        /// 在传感器或者回路中的序号
        /// </summary>
        public int snrloopIndex { get; set; }

        /// <summary>
        /// 读写属性 ture 只读  false 读写
        ///  只读，变量的值来源于内部计算
        /// </summary>
        public bool ReadOnly { get; set; }

        /// <summary>
        /// 数据类型 b - 位  i-整数  f-浮点 
        /// </summary>
        public DataTypeEnum DataType { get; set; }

        /// <summary>
        /// 初始值设定，只有在读写的自定义变量中用到
        /// </summary>
        public string? InitValue { get; set; }

        /// <summary>
        /// 自定义变量，关联的计算公式
        /// </summary>
        public string? ClacuateFormula { get; set; }

        /// <summary>
        /// 变量描述
        /// </summary>
        public string? Description { get; set; }

        /// <summary>
        /// 是否需要记录
        /// </summary>
        public bool IsRecord { get; set; }

        /// <summary>
        /// 记录周期 取100ms的整数倍
        /// </summary>
        public int RecordCycle { get; set; }

        /// <summary>
        /// 是否需要报警 0-不报警 1-高报警 2-低报警 3-高低报警
        /// </summary>
        public AlarmTypeEnum AlarmSetting { get; set; }

        /// <summary>
        /// 高报警
        /// </summary>
        public int  HighAlarmSet { get; set; }

        /// <summary>
        /// 低报警
        /// </summary>
        public int LowAlarmSet { get; set; }
    }
}
